﻿<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rsuser = 10;
$pageNum_rsuser = 0;
if (isset($_GET['pageNum_rsuser'])) {
  $pageNum_rsuser = $_GET['pageNum_rsuser'];
}
$startRow_rsuser = $pageNum_rsuser * $maxRows_rsuser;

mysql_select_db($database_conexao, $conexao);
$query_rsuser = "SELECT * FROM `admin` ORDER BY id_adm ASC";
$query_limit_rsuser = sprintf("%s LIMIT %d, %d", $query_rsuser, $startRow_rsuser, $maxRows_rsuser);
$rsuser = mysql_query($query_limit_rsuser, $conexao) or die(mysql_error());
$row_rsuser = mysql_fetch_assoc($rsuser);

if (isset($_GET['totalRows_rsuser'])) {
  $totalRows_rsuser = $_GET['totalRows_rsuser'];
} else {
  $all_rsuser = mysql_query($query_rsuser);
  $totalRows_rsuser = mysql_num_rows($all_rsuser);
}
$totalPages_rsuser = ceil($totalRows_rsuser/$maxRows_rsuser)-1;

$queryString_rsuser = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rsuser") == false && 
        stristr($param, "totalRows_rsuser") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rsuser = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rsuser = sprintf("&totalRows_rsuser=%d%s", $totalRows_rsuser, $queryString_rsuser);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Documento sem título</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>

<body>
<table width="960" align="center">
  <tr>
    <td colspan="2">
	<?php include ("../temadmin/cabecalho.php");?>

</td>
  </tr>
  <tr>
    <td colspan="2">
	<?php include "../temadmin/menu_vertical.php";
	?>
    </td>
  </tr>
  <tr>
    <td width="250">
	<?php include "../temadmin/menu.php";?>
    </td>
    <td width="698"><table width="99%">
      <tr>
        <th colspan="3" scope="col">Usuarios Administrativos</th>
        </tr>
      <tr>
        <td width="5%">&nbsp;</td>
        <td width="90%"><table width="103%">
          <tr bgcolor="#999999">
            <th width="7%" scope="col">id</th>
            <th width="19%" scope="col">Nome</th>
            <th width="18%" scope="col">Email</th>
            <th width="18%" scope="col">Login</th>
            <th width="26%" scope="col">Senha</th>
            <th colspan="2" scope="col">Ação</th>
            </tr>
          <?php do { ?>
            <tr bgcolor="#CCCCCC">
              <td><?php echo $row_rsuser['id_adm']; ?></td>
              <td><?php echo $row_rsuser['adm_nome']; ?></td>
              <td><?php echo $row_rsuser['adm_email']; ?></td>
              <td><?php echo $row_rsuser['adm_login']; ?></td>
              <td><?php echo $row_rsuser['adm_senha']; ?></td>
              <td width="6%"><a href="usu-editar.php?idadm=<?php echo $row_rsuser['id_adm']; ?>"><img src="img/Editar.png" width="16" height="16" /></a></td>
              <td width="6%"><a href="usu-excluir.php?idadm=<?php echo $row_rsuser['id_adm']; ?>"><img src="img/Excluir.png" width="16" height="16" /></a></td>
            </tr>
            <?php } while ($row_rsuser = mysql_fetch_assoc($rsuser)); ?>
          <tr bgcolor="#999999">
            <td colspan="7" align="right"><a href="usu-inserir.php"><img src="img/inserir.png" width="69" height="15" /></a></td>
          </tr>
          <tr>
            <td colspan="7">&nbsp;
              <table border="0">
                <tr>
                  <td><?php if ($pageNum_rsuser > 0) { // Show if not first page ?>
                      <a href="<?php printf("%s?pageNum_rsuser=%d%s", $currentPage, 0, $queryString_rsuser); ?>"><img src="img/First.gif" /></a>
                      <?php } // Show if not first page ?></td>
                  <td><?php if ($pageNum_rsuser > 0) { // Show if not first page ?>
                      <a href="<?php printf("%s?pageNum_rsuser=%d%s", $currentPage, max(0, $pageNum_rsuser - 1), $queryString_rsuser); ?>"><img src="img/Previous.gif" /></a>
                      <?php } // Show if not first page ?></td>
                  <td><?php if ($pageNum_rsuser < $totalPages_rsuser) { // Show if not last page ?>
                      <a href="<?php printf("%s?pageNum_rsuser=%d%s", $currentPage, min($totalPages_rsuser, $pageNum_rsuser + 1), $queryString_rsuser); ?>"><img src="img/Next.gif" /></a>
                      <?php } // Show if not last page ?></td>
                  <td><?php if ($pageNum_rsuser < $totalPages_rsuser) { // Show if not last page ?>
                      <a href="<?php printf("%s?pageNum_rsuser=%d%s", $currentPage, $totalPages_rsuser, $queryString_rsuser); ?>"><img src="img/Last.gif" /></a>
                      <?php } // Show if not last page ?></td>
                </tr>
              </table></td>
            </tr>
        </table></td>
        <td width="5%">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2">
	<?php include ("../temadmin/rodape.php");?>
    </td>
  </tr>
</table>


</body>
</html>
<?php
mysql_free_result($rsuser);
?>
